package com.zzy.banian.crm.service;

import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zzy.banian.crm.mapper.LeadMapper;
import com.zzy.banian.crm.domain.Lead;
import com.zzy.banian.crm.service.ILeadService;
import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.common.utils.text.Convert;

/**
 * 线索 服务层实现
 * 
 * @author zhangzuoyi
 * @date 2019-05-05
 */
@Service
public class LeadServiceImpl implements ILeadService 
{
	@Autowired
	private LeadMapper leadMapper;

	/**
     * 查询线索信息
     * 
     * @param id 线索ID
     * @return 线索信息
     */
    @Override
	public Lead selectLeadById(Integer id)
	{
	    return leadMapper.selectLeadById(id);
	}
	
	/**
     * 查询线索列表
     * 
     * @param lead 线索信息
     * @return 线索集合
     */
	@Override
	public List<Lead> selectLeadList(Lead lead)
	{
	    return leadMapper.selectLeadList(lead);
	}
	
    /**
     * 新增线索
     * 
     * @param lead 线索信息
     * @return 结果
     */
	@Override
	public int insertLead(Lead lead)
	{
		lead.setCreateBy(ShiroUtils.getLoginName());
		lead.setCreateTime(new Date());
	    return leadMapper.insertLead(lead);
	}
	
	/**
     * 修改线索
     * 
     * @param lead 线索信息
     * @return 结果
     */
	@Override
	public int updateLead(Lead lead)
	{
		lead.setUpdateBy(ShiroUtils.getLoginName());
		lead.setUpdateTime(new Date());
	    return leadMapper.updateLead(lead);
	}

	/**
     * 删除线索对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	@Override
	public int deleteLeadByIds(String ids)
	{
		return leadMapper.deleteLeadByIds(Convert.toStrArray(ids));
	}
	
}
